package au.com.iglootech.component;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.vaadin.data.Container;
import com.vaadin.data.Property;
import com.vaadin.ui.Table;

public class IGTTable extends Table {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static final String YES = "plan";
	private static final String NO = "lunched";

	public IGTTable()
	{
		super();
	}
	
	public IGTTable(String caption)
	{
		super(caption);
	}
	
	public IGTTable(String caption, Container dataSource)
	{
		super(caption, dataSource);
	}
	@Override
	protected String formatPropertyValue(Object rowId, Object colId,
			Property property) {
		// Format by property type
		if (property.getType() == Date.class) {
			SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
			return df.format((Date) property.getValue());
		} else if (property.getType() == Boolean.class) {
			if (property.getValue() == null || (Boolean) property.getValue()) {
				return YES;
			} else {
				return NO;
			}
		}

		return super.formatPropertyValue(rowId, colId, property);
	}
}
